package com.biyao.es.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * elasticsearch配置
 *
 * @author: hxs
 * @create: 2020/7/7
 */

@Configuration
public class ElasticSearchClientConfig {

    @Value("${spring.elasticsearch.rest.url}")
    private String esUrl;

    @Value("${spring.elasticsearch.rest.port}")
    private Integer esPort;

    @Bean
    public RestHighLevelClient restHighLevelClient() {
        return new RestHighLevelClient(RestClient.builder(new HttpHost(esUrl, esPort, "http")));
    }
} 